<template>
	<view class="page">
		<view v-for="(item, index) in list" :key="index" @click="handleToDetail(item)" class="item">
			<view class="item-info">
				<view class="item-info-left">
					<image v-if="index % 2 == 0" class="avatar" :src="item.awardImg || '/static/images/mall/my/icon_gift_3x.png'"></image>
					<image v-else class="avatar" :src="item.awardImg || '/static/images/mall/my/icon_fanxian_3x.png'"></image>
					<view class="base">
						<view class="base-item">
							<text class="name">{{ item.awardName }}</text>
							<text>* {{ item.awardUnitNum }}</text>
						</view>
						<view class="base-item ">
							<text class="base-hospital">来源:{{ item.spinWinName }}</text>
						</view>
					</view>
				</view>
				<view class="item-info-right">
					<!-- <text :class="statusClass">测色</text> -->
					<text :class="{ green: item.spinWinRecordState == 'finished', blue: item.spinWinRecordState == 'waitingSet' }" class="price">
						{{ item.spinWinRecordStateName }}
					</text>
				</view>
			</view>
			<view class="item-bottom">
				<text class="item-bottom-time">获奖时间：{{ item.createdTime }}</text>
				<!-- <text class="item-bottom-btn">查看</text> -->
			</view>
		</view>
		<view v-if="!loading && list.length" class="loading-more"><text class="loading-more-text">~~没有更多了~~</text></view>
		<tui-no-data imgUrl="/static/images/toast/img_nodata.png" v-if="!loading && !list.length">sorry,您未中过奖品...</tui-no-data>
	</view>
</template>

<script>
import { spinWinAwardListPage } from '@/service/spinwin.js';
export default {
	data() {
		return {
			param: {
				pageNum: 1,
				pageSize: 10
			},
			loading: false,
			list: []
		};
	},
	onLoad() {
		this.getSpinWinAwardListPage();
	},
	methods: {
		handleToDetail({ id }) {
			uni.navigateTo({
				url: 'detail?id=' + id
			});
		},
		async getSpinWinAwardListPage() {
			const resp = await spinWinAwardListPage({ awardType: 'other', ...this.param });
			const maps = {
				waitingSet: '请设置收货地址',
				waitingSend: '等待发货',
				finished: '完成'
			};
			this.list = resp.data.map(v => {
				v.spinWinRecordStateName = maps[v.spinWinRecordState];
				return v;
			});
		}
	}
};
</script>

<style scoped lang="scss">
view {
	display: flex;
	box-sizing: border-box;
}
.page {
	flex-direction: column;
}
.item {
	margin: 0 auto;
	width: 720upx;
	flex-direction: column;
	background-color: #ffffff;
	margin-top: 15upx;
	border-radius: 16upx;
	padding: 30upx;
	/* margin-left:16upx; */
}

.item-top {
	padding-bottom: 26upx;
	align-items: flex-end;
	justify-content: space-between;
	border-bottom-width: 1upx;
	border-bottom-color: #f5f5f5;
	.item-patient,
	.item-duration {
		align-items: center;
	}

	.item-patient {
		font-size: 26upx;
		color: #66789c;

		.item-patient-name {
			color: #323437;
		}
	}
	.item-duration {
		font-size: 26upx;
		color: #66789c;

		.item-duration-value {
			color: #323437;
		}
	}
}
.item-status-left {
	font-size: 34upx;
	color: #323437;
	line-height: 48upx;
	font-weight: bolder;
}
.item-status-right {
	color: #f87d6f;
	font-size: 24upx;
	line-height: 48upx;
}
.item-1 .item-status-right {
	color: #a9b6c7;
}
.item-2 .item-status-right {
	color: #45ceb3;
}
.item-3 .item-status-right {
	color: #3291f9;
}
.item-info {
	align-items: center;
	justify-content: space-between;
	padding-top: 26upx;

	.item-info-left {
		.avatar {
			width: 100upx;
			height: 100upx;
			border-radius: 70upx;
			margin-right: 20upx;
		}
		.base {
			flex-direction: column;
			.base-item {
				flex-direction: row;
				text {
					font-size: 26upx;
					line-height: 48upx;
					color: #323437;
					margin-right: 10upx;
				}
				.name {
					font-size: 32upx;
					font-weight: 500;
				}
			}
			.base-hospital {
				width: 350upx;
				lines: 1;
				text-overflow: ellipsis;
			}
		}
	}
	.item-info-right {
		flex-direction: column;
		align-items: flex-end;
		.order-status-unpaid {
			color: #f87d6f;
			font-size: 24upx;
		}
		.order-status-complete {
			color: #3291f9;
		}
		.order-status-paid {
			color: #45ceb3;
		}
		.order-status-canceled {
			color: #a9b6c7;
		}
		.price {
			text-align: center;
			font-size: 34upx;
			line-height: 50upx;
			color: #3291f9;
			font-weight: bolder;
		}
	}
}
.item-icon {
	width: 22upx;
	height: 22upx;
	margin-right: 12upx;
}
.item-label {
	font-size: 26upx;
	color: #66789c;
	line-height: 42upx;
}

.item-bottom {
	justify-content: space-between;
	align-items: center;
	margin-top: 30upx;
}
.item-bottom-time {
	color: #a9b6c7;
	font-size: 24upx;
	line-height: 48upx;
}
.item-bottom-btn {
	color: #ffffff;
	background-color: #3291f9;
	border-radius: 10upx;
	padding: 10upx 23upx;
}
.ml8 {
	margin-left: 8upx;
}
.ml6 {
	margin-left: 6upx;
}
.green {
	color: #19be6b !important;
}
.blue {
	color: $primary !important;
}
</style>
